package com.sls.core.util;

import java.util.regex.Pattern;

/**
 * 
 * @description 字符串相关操作
 * @author Wangxuegang
 * @date  2012-12-4
 */
public class ProcessString {

	/**
	 * 检查字符串中是否含有“元”
	 * @param str
	 * @return
	 */
	public static boolean isContainYuan(String str){
		boolean flag = false;
		if (str != null && !("".equals(str))) {
			if (str.indexOf("元") != -1) {
				flag = true;
			}else {
				flag = false;
			}
		}
		
		return flag;
	}
	
	/**
	 * 判断“元”前面字符是否是数字字符
	 * @param str
	 * @return
	 */
	public static boolean isHasDigital(String str){
		boolean flag = false;
		String strVal = "";
		if (str != null && !("".equals(str))){
			int index = str.indexOf("元");
			int indexVal = 0;
			if (index > 0) {
				indexVal = index - 1;
			}
			char ch = str.charAt(indexVal);
			strVal = ch + "";
		}
		Pattern pattern = Pattern.compile("[0-9]*"); 
		flag = pattern.matcher(strVal).matches(); 

		return flag;
	} 
	
//	public static void main(String[] args){
//	boolean flag = isHasDigital("");
//		System.err.println(flag);
//	}
	
}
